[C# n MySQL] Creating a database using Connector/NET Programming?

Posted by yeeen on Stack Overflow See other posts from Stack Overflow or by yeeen
Published on 2010-03-28T10:22:44Z Indexed on 2010/03/28 10:33 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

How to create a database using connector/net programming? How come the following doesn't work?

    string connStr = "server=localhost;user=root;port=3306;password=mysql;";
    MySqlConnection conn = new MySqlConnection(connStr);
    MySqlCommand cmd;
    string s0;

    try
    {
        conn.Open();
        s0 = "CREATE DATABASE IF NOT EXISTS `hello`;";
        cmd = new MySqlCommand(s0, conn);
        conn.Close();
    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about mysql